package com.amit.hibernate;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;

public class Lab1 {

	public static void main(String[] args) {
		
		
		SessionFactory sessionfactory=ChibernateUtil.getfactory();
		Session session=sessionfactory.openSession();
		Transaction tx=session.beginTransaction();
		//1.insert the data
		Customer cust=new Customer("amit123","amit@gmail.com");
		
		session.save(cust);
		System.out.println("record inserted");
		
		//2.updating the record
		Customer cust1=(Customer) session.load(Customer.class, 4);
		
		cust1.setCname("ajay yadav16");
		cust1.setEmail("anil@gmail.com");
		session.update(cust1);
		System.out.println("Record updated");
		
		
		tx.commit();
		session.close();

	}

}
